//
//  ViewController.swift
//  SwiftBluetoothScanDemo1
//
//  Created by caijinglong on 2017/9/9.
//  Copyright © 2017年 sxw. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    let helper = BluetoothHelper.shared

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let button = UIButton(type: UIButtonType.system)
        button.setTitle("输入", for: UIControlState.normal)
        button.frame = CGRect(x: 100, y: 100, width: 80, height: 30)
        self.view.addSubview(button)
        button.addTarget(self, action: #selector(print), for: UIControlEvents.touchUpInside)
        
        let button2 = UIButton(type: UIButtonType.system)
        button2.setTitle("连接", for: UIControlState.normal)
        self.view.addSubview(button2)
        button2.frame = CGRect(x: 100, y: 150, width: 80, height: 30)
        button2.addTarget(self, action: #selector(startScan), for: UIControlEvents.touchUpInside)
    }

    func print(){
        do {
            try self.helper.writeText(text: "测试数据\n")
            try self.helper.writeText(text: "TestText\n")
        } catch {
            NSLog("打印发生错误")
        }
    }
    
    func startScan(){
        helper.startScan(name:"QSPrinter")
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

